home *** CD-ROM | disk | FTP | other *** search
- /* $VER: 1.0, ©1994 Engelbert Roidl.
- ** engelbert.roidl@extern.uni-regensburg.de
- **/
-
- /*
- * Project.ged
- * Save windowpositions, cursorpositions and filenames.
- *
- * Commands:
- * NEW - Add a new project.
- * Request projectdirectory and projectname.
- * The user specific code in this script should set
- * up a direktory at "projectdirektory" with the name "projectname".
- * It should copy defaultfiles for your work in this direktory.
- *
- * OPEN - Opens a existing project.
- * It requests the PROJECT-file in your project's direktory.
- * After this it will open all files and it reads all important
- * files in this directory into the Project-requester form GoldEd.
- * You may modify this readprocess to use e.g. Modula or Pascal.
- *
- * CLOSE - Close the current project.
- * Every time you open or add a new project you have to close it.
- * All important parameter will be saved.
- *
- * Installation:
- * Make three new menu entries. Set the command type to ARexx.
- * New Project: Cmd: GoldEd:arexx/project.ged new
- * Open Project: Cmd: GoldEd:arexx/project.ged open
- * Close Project: Cmd: GoldEd:arexx/project.ged close
- *
- * Usage:
- * 1. Opening a new project:
- * Every time you want to start a new project, you have to
- * open a NEW PROJECT with this script.
- * After you have started the script via
- *
- * Golded:arexx/project.ged new
- *
- * you will be asked for the projects home.
- * Select a directory (e.g. RAM:). Then you can enter the name
- * of your new project (e.g. TEST). The script will
- * make a new directory. The name will be RAM:TEST.
- * After that it changes the editors directory to this.
- *
- * 2. Closing a project:
- * If you have opened a new or an existing project and you
- * stop working at this day, you have to close this project via
- *
- * Golded:arexx/project.ged close
- *
- * The script will save the position and file of each opened
- * window (ATTENTION: Freezed windows will not be saved!!!).
- *
- * 3. Opening an exsiting project:
- * If you want to start working the next day, you have to open
- * the project via
- *
- * Golded:arexx/project.ged open
- *
- * You will be asked for the PROJECT-file of the project. It
- * can be found in the projects directory. In this case:
- * RAM:TEST/PROJECT.
- * Select this file via the upcoming filerequester.
- * The script changes the editors directory to the selected.
- * Then it reads the PROJECT-file and opens all windows at it's
- * old positions.
- * After that all files (pattern!!) in this directory will be
- * inserted in GoldEds Project-Requester.
- *
- */
-
- OPTIONS RESULTS /* enable return codes */
-
- address 'GOLDED.1'
-
- 'LOCK CURRENT' /* lock GUI, gain access */
- OPTIONS FAILAT 6 /* ignore warnings */
- SIGNAL ON SYNTAX /* ensure clean exit */
-
- /* ------------------------- INSERT YOUR CODE HERE: ------------------ */
-
- arg function /* Arguments */
-
- 'QUERY CAT'
- isGerman = (result = "deutsch")
-
- select
- /******************************************************************************
- * NEW
- * Open NEW Project.
- ******************************************************************************/
- when function = 'NEW' then
- do
- 'QUERY USER20 VAR PRJTEST'
- if (prjtest ~= TRUE) then
- do /* No Project opened */
- 'QUERY SCREEN VAR SCR'
- if (isGerman) then
- do
- shell COMMAND
- 'requestfile >t:dir title "Projektverzeichnis" drawersonly pubscreen ' result
- dirok = rc
- shell
- 'REQUEST STRING BODY="Bitte einen Projektnamen eingeben" BUTTON="OK||Abbruch" VAR NAME'
- end
- else
- do
- shell COMMAND
- 'requestfile >t:dir title "Projectdirectory" drawersonly pubscreen ' result
- dirok = rc
- shell
- 'REQUEST STRING BODY="Enter projectname" BUTTON="OK||Cancel" VAR NAME'
- end
-
- if ( (rc = 0) & (dirok = 0) ) then
- do /* Enter Directory */
- if open('dir',"t:dir", 'R') then
- do
- dir = readln('dir')
-
- /* Remove Quotes */
- a = delstr(dir , 1 , 1)
- dir = delstr( a , length(a) , 1 )
- projekt = dir || name
-
- /* Set Current GoldED-Directory */
- 'DIR NEW' projekt
-
- CALL setenv("PROJECT", projekt)
-
- /* Setup Project */
- /****************************************************************************
- * Add user-specific code here
- ****************************************************************************/
-
- /* Make Directory >projekt< */
- shell COMMAND
- 'sc:c/scsetup "' || projekt || '"'
- shell
- /* Copy Defaultfiles to >projekt< */
-
- /****************************************************************************
- * End user-specific code
- ****************************************************************************/
-
- call close ('dir')
- 'SET USER 20 VALUE TRUE' /* Projekt opened */
- end
- end
- else
- do
- 'UNLOCK'
- EXIT
- end
- end
- else
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Noch ein Projekt geöffnet||Bitte zuerst schließen"'
- else
- 'REQUEST PROBLEM="There is a project opened||Please close it first"'
- 'UNLOCK'
- EXIT
- end
- end
-
- /******************************************************************************
- * OPEN
- * Open Projekt.
- ******************************************************************************/
- when function = 'OPEN' then
- do
- 'QUERY USER20 VAR PRJTEST'
- if (prjtest ~= TRUE) then
- do /* No Project openend */
- 'QUERY SCREEN VAR SCR'
- if (isGerman) then
- do
- shell COMMAND
- 'requestfile >t:dir title "Projekt auswählen"
- PATTERN PROJECT ACCEPTPATTERN PROJECT
- pubscreen ' result
- dirok = rc
- shell
- end
- else
- do
- shell COMMAND
- 'requestfile >t:dir title "Select Project"
- PATTERN PROJECT ACCEPTPATTERN PROJECT
- pubscreen ' result
- dirok = rc
- shell
- end
-
- if ( dirok = 0 ) then
- do /* Enter Directory */
- if open('dir',"t:dir", 'R') then
- do
- dir = readln('dir')
-
- /* Remove Quotes */
- a = delstr(dir , 1 , 1)
- projekt = delstr( a , length(a) , 1 )
-
- /* Remove PROJECT */
- if (right(projekt,7) = 'PROJECT') then
- projekt1 = delstr(projekt,length(projekt)-6)
-
- if (right(projekt1,1) = '/') then
- projekt2 = delstr(projekt1,length(projekt1))
-
- /* => projekt: read from t:dir */
- /* projekt1: without PROJECT */
- /* projekt2: without / */
-
- /* Current GoldED directory */
- 'DIR NEW' projekt2
- CALL setenv("PROJECT", projekt2)
-
- /* Setup Projectlist */
- /****************************************************************************
- * Add user-specific code here
- ****************************************************************************/
-
- shell COMMAND
- 'list >t:dd files lformat "%n" "'projekt1'#?makefile" '
- 'list >>t:dd files lformat "%n" "'projekt1'#?.c"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.cc"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.cpp"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.cxx"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.a"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.asm"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.h"'
- 'list >>t:dd files lformat "%n" "'projekt1'#?.i"'
- shell
-
- /****************************************************************************
- * End user-specific code
- ****************************************************************************/
-
- if open('files', "t:dd" , 'R') then
- do
- do while ende~=0
- file = readln('files')
- if ~eof('files') then
- do
- 'PROJECT ADD ' file
- ende = 1
- end
- else
- ende = 0
- end
- CALL close('files')
- end
-
- if open('prj', projekt , 'R') then
- do
- anzahl = readln('prj')
- do i=1 to anzahl
- file = readln('prj')
- x = readln('prj')
- y = readln('prj')
- w = readln('prj')
- h = readln('prj')
- line = readln('prj')
-
- 'OPEN SMART ' file
- 'GOTO LINE' line 'UNFOLD=TRUE'
- 'WINDOW WIDTH ' w ' HEIGHT ' h ' X ' x ' Y ' y
- end
- call close('prj')
- end
- else
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Open fehlgeschlagen!"'
- else
- 'REQUEST PROBLEM="Open failed!"'
- 'UNLOCK'
- EXIT
- end
- call close('dir')
- 'SET USER 20 VALUE TRUE' /* Project opened */
- end
- else
- do
- CALL setenv("PROJECT", "")
- if (isGerman) then
- 'REQUEST PROBLEM="Keine Projektdatei vorhanden||Bitte zuerst schließen"'
- else
- 'REQUEST PROBLEM="No Projectfile available"'
- 'UNLOCK'
- EXIT
- end
- CALL close(prj)
-
-
- end
- end
- else
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Noch ein Projekt geöffnet||Bitte zuerst schließen"'
- else
- 'REQUEST PROBLEM="There is a project opened||Please close it first"'
- 'UNLOCK'
- EXIT
- end
- end
- /******************************************************************************
- * CLOSE
- * Close Project.
- ******************************************************************************/
- when function = 'CLOSE' then
- do
- 'QUERY USER20 VAR PRJTEST'
- if (prjtest = TRUE) then
- do
- path = getenv("PROJECT")
-
- if(right(path, 7) ~= 'PROJECT') then
- do
- /* append /PROJECT */
- if (right(path,1) ~= '/' & right(path,1) ~= ':' ) then
- projekt = path || '/' || 'PROJECT'
- else
- projekt = path || 'PROJECT'
- end
- else
- projekt = path
-
- if OPEN('p', projekt , 'W') then
- do
- 'PROJECT CLR'
- 'MORE'
- 'NAME NEW RAM:OhneNamen'
- 'QUERY WINDOWS VAR WINDOWSANZAHL' /* Get Number of Windows */
- 'WINDOW ORDINAL 0 QUIET'
- a = writeln('p', windowsanzahl-1)
-
- do i=0 to windowsanzahl+1
- 'QUERY DOC VAR WINNAME'
- 'QUERY WINH VAR WINH' /* Get Windowparameter */
- 'QUERY WINW VAR WINW'
- 'QUERY X VAR X'
- 'QUERY Y VAR Y'
- 'QUERY ABSLINE VAR LINE'
-
- if( winname ~= "RAM:OhneNamen") then
- do
- a = writeln('p', winname )
- a = writeln('p', x )
- a = writeln('p', y )
- a = writeln('p', winw )
- a = writeln('p', winh )
- a = writeln('p', line )
-
- /* If File modified */
- 'QUERY MODIFY VAR MODIFIED'
- if(modified = TRUE) then
- do /* Request: Save File? */
- if (isGerman) then
- 'REQUEST BODY="Datei wurde verändert.| Speichern ?" BUTTON="SAVE|Abbrechen"'
- else
- 'REQUEST BODY="File mofified.| Save ?" BUTTON="SAVE|Abbrechen"'
- if(result = 1) then
- 'SAVE ALL'
- end
- /* Close Window */
- 'QUIT FORCE'
- end
- 'WINDOW NEXT QUIET' /* Next Window */
- end
- call close('p')
- 'SET USER 20 VALUE FALSE' /* Project NOT opened */
- end
- else
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Open fehlgeschlagen!"'
- else
- 'REQUEST PROBLEM="Open failed!"'
-
- 'UNLOCK'
- EXIT
- end
- end
- else
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Kein Projekt geöffnet"'
- else
- 'REQUEST PROBLEM="No Project opened"'
- 'UNLOCK'
- EXIT
- end
- end
-
- otherwise
- do
- if (isGerman) then
- 'REQUEST PROBLEM="Unbekannte Option"'
- else
- 'REQUEST PROBLEM="Unknown Command"'
- 'UNLOCK'
- end
- end
-
- /* ---------------------------- END OF YOUR CODE ----------------------- */
-
- 'UNLOCK' /* VERY important: unlock GUI */
- EXIT
-
- SYNTAX:
-
- SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
- 'UNLOCK'
- EXIT
-
-
- getenv: procedure /* when will ARexx supply GetEnv/SetEnv ? */
- PARSE ARG name
-
- IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
- gives = readln(TEMPFILE)
- CALL close TEMPFILE
- END
- ELSE gives = ""
-
- RETURN gives
-
- CALL setenv: procedure
- PARSE ARG name,content
-
- ADDRESS COMMAND "SetEnv" name content
-
- RETURN
-
-